package cn.wolfcode.crm.util;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public abstract class XlsMapping {
    public static final String[][] EMPLOYEE_MAP = {
        {"用户名", "getUsername"},
        {"真实姓名", "getRealname"},
        {"邮箱", "getEmail"},
        {"部门名称", "getDept", "getName"},
        {"电话", "getTel"},
        {"入职时间", "getHiredate"},
        {"状态", "isState"},
        {"是否是管理员", "isAdmin"},
    };
    public static Object getValue(Object obj,int index, String[] arr) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Method method = obj.getClass().getMethod(arr[index]);
        Object res = method.invoke(obj);
        if (res == null) {
            return null;
        }
        if (index == arr.length - 1) {
            return res;
        }
        return getValue(res, index + 1, arr);
    }
}
